package com.wgts.wgts.mvp.model.imp;

import com.wgts.wgts.mvp.model.IShoppingCarModel;
import com.wgts.wgts.netmodle.HttpResultSubscriber;
import com.wgts.wgts.netmodle.NetService;
import com.wgts.wgts.netmodle.req.ChangeGoodsNumberRequest;
import com.wgts.wgts.netmodle.req.DeleteShopRequest;
import com.wgts.wgts.netmodle.resp.CurrentEntity;
import com.wgts.wgts.netmodle.resp.ShopCarListEntity;
import com.wgts.wgts.rxjava.MVPResultSubscriber;

import java.util.List;

import rx.Observable;
import rx.Subscriber;


/*
 *
 *
 *   data:2018/9/619:11
 *
 */public class ShoppingCarModel implements IShoppingCarModel {
     private NetService netService;

    public ShoppingCarModel(NetService netService) {
        this.netService = netService;
    }

    @Override
    public void getShopCarList(HttpResultSubscriber<List<ShopCarListEntity>> subscriber) {
        netService.shopCarList(subscriber);
    }


    @Override
    public void addOrSubtrctShopping(ChangeGoodsNumberRequest request, HttpResultSubscriber<Integer> subscriber) {
        netService.changeGoodsNumber(request, subscriber);
    }

    @Override
    public void deleteShopping(final Integer Ppoition, final Integer position, MVPResultSubscriber<String> subscriber) {
        Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(Subscriber<? super String> subscriber) {
                /*dates.get(Ppoition).getShoppingEntities().remove(dates.get(Ppoition).getShoppingEntities().get(position));
                checkDatas();
                changeStore();
                subscriber.onNext("sucess");*/
            }
        }).subscribe(subscriber);
    }

    @Override
    public void deleteAllShopping(DeleteShopRequest request, HttpResultSubscriber<CurrentEntity> subscriber) {
        netService.deleteGoods(request, subscriber);
    }


}
